﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.IO;
using System.Security.Cryptography;

namespace RssReader.Core.Global
{
	public class Utility
	{
		#region Private Properties

		#endregion

		#region Public Properties

		#endregion

		#region Constructors

		#endregion

		#region Private Methods

		#endregion

		#region Public Methods
		public static bool ExistsEmail(string email)
		{
			string path = GetDataPath(email);
			return File.Exists(path);
		}

		public static string GetDataPath(string email)
		{
			return Path.Combine(HttpContext.Current.Server.MapPath("~/App_Data/"), email + ".xml");
		}

		public static string EncryptString(string source)
		{
			MD5 md5 = new MD5CryptoServiceProvider();
			byte[] bytes = md5.ComputeHash(UnicodeEncoding.UTF8.GetBytes(source));
			return BitConverter.ToString(bytes).Replace("-","");
		}
		#endregion
	}
}
